home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 29
/
Volume 29 - JOGO DISK .iso
/
Games
/
jungle_adventure.swf
/
scripts
/
__Packages
/
GameSpring.as
< prev
next >
Wrap
Text File
|
2006-11-29
|
2KB
|
65 lines
class GameSpring extends SSObject
{
var assetID = "spring";
var strength = 1200;
var momentumTransfer = 0;
var time = 0;
var editor_isItem = true;
var editor_name = "Spring";
var editor_canRotate = true;
var editor_args_names = ["angle","strength"];
var editor_args_values = [0,GameSpring.prototype.strength];
var editor_args_types = ["number","number"];
var editor_args_options = [[-360,360,1],[0,5000,20]];
var editor_args_descriptions = ["",""];
var editor_args_mode = [0,0];
var editor_args_component = ["NumericStepper","NumericStepper"];
function GameSpring(angle, strength)
{
super();
this.addEvent("rotate",this.onRotate);
if(strength != null)
{
this.strength = Number(strength);
}
this.setAngle(!angle ? this.angle : angle);
}
function onAddToWorld()
{
this.zone = new SSZone(SSZone.SPHERE,this.radius,this.zone_onCollide,this);
this.world.addObject(this.zone);
this.onMove();
}
function onMove()
{
this.zone.moveTo(this.x + 20 * this.direction.x,this.y + 20 * this.direction.y,this.z);
}
function onRotate(angle)
{
var _loc2_ = angle * 3.141592653589793 / 180;
this.direction = new Vector(Math.sin(_loc2_),- Math.cos(_loc2_),0);
this.onMove();
}
function zone_onCollide(obj)
{
if(this.time + 0.1 > this.world.time)
{
return undefined;
}
this.time = this.world.time;
GameSound.playSound("Spring");
obj.jumpTime = 0;
obj.velocity.x = this.direction.x * (this.strength + obj.velocity.x * this.momentumTransfer);
obj.velocity.y = this.direction.y * (this.strength + obj.velocity.y * this.momentumTransfer);
return GDK.Node.COLLISION_CANCEL;
}
function editor_onDisplay(target, external)
{
target._rotation = this.angle;
target.clear();
target.lineStyle(0,52479);
var _loc3_ = this.strength - (1 - Math.log(this.strength) / 8) * this.strength * 3;
target.lineTo(0,- _loc3_);
}
}